package com.xyoto.takeawayBusiness.controller;

import com.xyoto.takeawayBusiness.aspect.annotation.RequiresLogin;
import com.xyoto.takeawayBusiness.dto.AddTakeawayDTO;
import com.xyoto.takeawayBusiness.dto.BillDTO;
import com.xyoto.takeawayBusiness.dto.UpdateTakeawayDTO;
import com.xyoto.takeawayBusiness.service.ShopService;
import com.xyoto.takeawayBusiness.utils.PageUtils;
import com.xyoto.takeawayBusiness.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @Description
 * @Author: TingFeng
 * @CreateTime: 2022/5/4  15:15
 */
@Api(tags = "店铺中心模块")
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;


    @RequiresLogin
    @ApiOperation("获取店铺资料")
    @GetMapping("/getShopData")
    public Result getShopData(@NotNull
                              @Min(value = 0,message = "最小值为0")
                              @RequestParam("shopId") Integer shopId){
        return shopService.getShopData(shopId);
    }

    @RequiresLogin
    @ApiOperation("获取外卖管理")
    @GetMapping("/getTakeaway")
    public Result getTakeaway(@NotNull
                              @Min(value = 0,message = "最小值为0")
                              @RequestParam("shopId") Integer shopId){
        return shopService.getTakeaway(shopId);
    }

    @RequiresLogin
    @ApiOperation("分页获取账单页")
    @GetMapping("/getBill")
    public Result getBill(@Valid PageUtils pageUtils, @Valid BillDTO billDTO){
        return shopService.getBill(pageUtils,billDTO);
    }
    @RequiresLogin
    @ApiOperation("修改外卖管理")
    @PostMapping("/updateTakeaway")
    public Result updateTakeaway(@Valid UpdateTakeawayDTO takeawayDTO){
        return shopService.updateTakeaway(takeawayDTO);
    }
    @RequiresLogin
    @ApiOperation("新增外卖管理")
    @PostMapping("/addTakeaway")
    public Result addTakeaway(@Valid AddTakeawayDTO addTakeawayDTO){
        return shopService.addTakeaway(addTakeawayDTO);
    }
}
